O'Reilly : Java Database Best Practices by By

O'Reilly : Java Database Best Practices by By

Author:By
Language: eng
Format: epub
ISBN: 0-596-00522-9
Publisher: O'Reilly
Published: 2011-10-04T19:40:09.236732+00:00


7.3 EJB BMP with JDO

From a JDO perspective, persisting EJBs as part of a bean-managed persistence model has little difference from persisting other kinds of objects. The most common difference is that you tend to be in a managed environment when working with EJBs; similarly, you tend to be in a nonmanaged environment when building other kinds of applications. You can, of course, build web applications in a managed environment and EJB applications that use bean-managed transactions.

One key differentiator between working with JDO in a managed J2EE container versus a nonmanaged environment—besides the obvious impact of transaction management—is the way you reference the PersistenceManagerFactory class. In a non-J2EE container or a nonmanaged environment, you pass a set of properties to the JDOHelper class. The JDOHelper class then hands you the appropriate PersistenceManagerFactory.

When working in a J2EE container, you can rely on JNDI to provide you with a PersistenceManagerFactory without worrying about properties:

Context ctx = new InitialContext( ); PersistenceManagerFactory factory; factory = (PersistenceManagerFactory)ctx.lookup("jdo/pmf");



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.